package apis

import (
	"gitee.com/byx_darwin/ncloud-go/core"
	"gitee.com/byx_darwin/ncloud-go/core/net/consts"
)

type CreatePreloadConditions struct {
	Urls      []string `json:"urls"`
	StartTime int64    `json:"start_time"`
}

type CreatePreloadRequest struct {
	core.NCloudRequest
	CreatePreloadConditions
}

func NewCreatePreloadContent(urls []string) *CreatePreloadRequest {
	return &CreatePreloadRequest{
		NCloudRequest: core.NCloudRequest{
			Path:   "/content",
			Method: consts.MethodPost,
		},
		CreatePreloadConditions: CreatePreloadConditions{
			Urls: urls,
		},
	}
}

func NewCreatePreloadContentWithParams(urls []string, startTime int64) *CreatePreloadRequest {
	return &CreatePreloadRequest{
		NCloudRequest: core.NCloudRequest{
			Path:   "/content",
			Method: consts.MethodPost,
		},
		CreatePreloadConditions: CreatePreloadConditions{
			Urls:      urls,
			StartTime: startTime,
		},
	}
}

type PreloadContentData struct {
	TaskID string `json:"task_id"`
}
type CreatePreloadContentResponse struct {
	Ok      bool               `json:"ok"`
	Msg     string             `json:"msg"`
	Data    PreloadContentData `json:"data,omitempty"`
	TrackID string             `json:"track_id"`
}

type CreateRefreshConditions struct {
	Urls []string `json:"urls"`
	Type string   `json:"type"`
}
type CreateRefreshRequest struct {
	core.NCloudRequest
	CreateRefreshConditions
}

func NewCreateRefreshContent(urls []string, refreshType string) *CreateRefreshRequest {
	return &CreateRefreshRequest{
		NCloudRequest: core.NCloudRequest{
			Path:   "/content",
			Method: consts.MethodPut,
		},
		CreateRefreshConditions: CreateRefreshConditions{
			Urls: urls,
			Type: refreshType,
		},
	}
}

type RefreshContentData struct {
	TaskID string `json:"task_id"`
}
type CreateRefreshContentResponse struct {
	Ok      bool               `json:"ok"`
	Msg     string             `json:"msg"`
	Data    PreloadContentData `json:"data,omitempty"`
	TrackID string             `json:"track_id"`
}
